package com.etms.controller;

import com.etms.pojo.DeptItem;
import com.etms.service.DeptService;
import com.etms.vo.DeptParmas;
import com.etms.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("dept")
public class DeptController {

    @Autowired
    DeptService deptService;
    @GetMapping("getList/{id}")
    public Result getList(@PathVariable("id")Integer id){
        //部门id 1采 2生 3销
        return deptService.findListById(id);
    }


    @GetMapping("getItemListById/{id}")
    public Result getItemById(@PathVariable("id")Integer id){
        //部门id 1采 2生 3销
        return deptService.findItemListById(id);
    }

    @PostMapping("updateOrAdd")
    public Result updateOrAdd(@RequestBody DeptItem deptItem){

        return deptService.updateOrAdd(deptItem);
    }

    @PostMapping("getItemById")
    public Result getItemById(@RequestBody DeptParmas deptParmas){
        return deptService.findItemByDaidAndXid(deptParmas.getDaId(),deptParmas.getXid());
    }

    @PostMapping("delItemById")
    public Result delItemById(@RequestBody DeptParmas deptParmas){
        return deptService.delItemById(deptParmas.getDaId(),deptParmas.getXid());
    }
}